#!/bin/sh

# 加载工具类
. /etc/idnewnil/utils.sh

# 配置ssh
PUBLIC_KEY=$(getstr '.ssh.public_key')
if [ "${PUBLIC_KEY}" ]; then
    echo "${PUBLIC_KEY}" >>/etc/dropbear/authorized_keys
fi
uci set dropbear.@dropbear[0].Interface='lan'
uci add dropbear dropbear
uci set dropbear.@dropbear[-1].Interface='wan'
uci set dropbear.@dropbear[-1].Port='2201'
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-SSH'
uci add_list firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].src='wan'
uci set firewall.@rule[-1].dest_port='2201'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit
/etc/init.d/dropbear restart
